#ifndef _CHUNK_RENDER_H_
#define _CHUNK_RENDER_H_

#include"Common.h"
#include"VertexArray.h"
#include"BlockRender.h"
#include"Shader.h"
#include"Chunk.h"
#include"NoCopyable.h"

#include<memory>
#include<string>
#include<vector>

namespace Craft{

	/*
	@brief
	*/
	class ChunkRender : public NoCopyable
	{
	public:

		ChunkRender() = default;
		ChunkRender(Chunk* chunk);
		ChunkRender(ChunkRender&& rhs);
		ChunkRender& operator=(ChunkRender&& rhs);

		~ChunkRender();

		void render(Shader shader);

	    void add_Block(TexInfo tex[], glm::vec3 pos);
		void add_Plant(TexInfo tex,   glm::vec3 pos);

		void render_update();

		bool adjacent_test(Block curr,Block neigh);

		GLfloat vertexAO(const glm::vec3& pos, const glm::vec3& offset1, const glm::vec3& offset2, const glm::vec3&corner);
		Block   get_block_direction(const glm::vec3& pos, int direction);
		//void    filp_quad(glm::vec3 position[],GLuint index[],GLfloat occlusion[],int direction);

		static VertexArrays&  get_va();
		static ElementsBuffe& get_eb();

	private:

		Chunk* m_chunk;

		static VertexArrays  va;
		static ElementsBuffe eb;
	
		VertexBuffer m_buffer;
		TexBlockRender rend;

		unsigned int tri_render_count;
	};

}

#endif